define(['jquery','swiper'
],function ($,swiper) {
  var initModule,banner,iabout,liucheng;
  banner = function(){
    var iswiper = new Swiper('.index .banner .swiper-container', {
        pagination: '.index .banner .swiper-pagination',
        paginationClickable: true,
        speed:3000,
        autoplay:3000,
        loop:true
    });
  };

  iabout = function(){
    var coperswiper = new Swiper('.i_about .swiper-container', {
        // pagination: '.i_about .swiper-pagination',
        // paginationClickable: true,
        slidesPerView: 3,
        speed:1000,
        spaceBetween: 100
    });
    $('.coper .ctrl_l').click(function(){
      coperswiper.slidePrev();
    });
    $('.coper .ctrl_r').click(function(){
      coperswiper.slideNext();
    });
  };

  liucheng = function(){
    var liuchengswiper = new Swiper('.liucheng .swiper-container', {
        speed:1000,
        effect:'fade',
        fade: {
            crossFade: false,
        }
    });
    $('.index .liucheng .inner .liucheng-nav .item').hover(function(){
      $('.index .liucheng .inner .liucheng-nav .item').removeClass('on');
      $(this).addClass('on');
      var i = $(this).index();
      liuchengswiper.slideTo(i, 1000, false);
    });
    $('.button-prev').click(function(){
      if(liuchengswiper.activeIndex>0){
        $('.index .liucheng .inner .liucheng-nav .item').removeClass('on');
        $('.index .liucheng .inner .liucheng-nav .item').eq(liuchengswiper.activeIndex-1).addClass('on');
      }
      liuchengswiper.slidePrev();
    })
    $('.button-next').click(function(){
      if(liuchengswiper.activeIndex+1<4){
        $('.index .liucheng .inner .liucheng-nav .item').removeClass('on');
        $('.index .liucheng .inner .liucheng-nav .item').eq(liuchengswiper.activeIndex+1).addClass('on');
      }
      liuchengswiper.slideNext();
    });
  };

  initModule = function(callbak){
    console.log('index is load');
    banner();
    iabout();
    liucheng();
    callbak(0);

  };
  return {
    initModule:initModule
  };
})
